﻿Namespace Sigortali.Analik
	Module Functions

		Function MuracaatRaporu(ByVal Process As Token, ByVal sno As String) As Recordset
			Q("select t.*,i.isyeriadi from (")
			Q("select repsube,sno,dosyano,'İşgöremezlik' as tur,murtar,dosyaacik,sanabastar as bastar,sanasontar as bittar,isyerino,dogumtar,onay,odememe from ssd..sagecici union all")
			Q("select repsube,sno,dosyano,'Doğum',dogmurtar as murtar,dosyaacik,null,null,isyerino,dogumtar,onaydog,dogodememe from ssd..sanalik union all")
			Q("select repsube,sno,dosyano,'Emzirme',emzmurtar as murtar,dosyaacik,null,null,isyerino,dogumtar,onayemz,emzodememe from ssd..sanalik union all")
			Q("select repsube,sno,dosyano,'Gebelik',gebmurtar as murtar,dosyaacik,null,null,isyerino,dogumtar,onaydog,dogodememe from ssd..sanalik) t")
			Q("left join ssd..isyerigenel i on t.isyerino = i.isyerino")
			Q("where sno = :sno order by dosyano, tur")
			Return Process.OpenSQL("*", sno)
		End Function

		Function MaktuOdemeRaporu(ByVal Process As Token, ByVal sno As String) As Recordset
			Q("select t.*,i.isyeriadi from (")
			Q("select repsube,sno,'Gebelik' as tur,dosyano,dosyaacik,odemetar,fisno,isyerino,pogs,kime,gebodemik as odemik from ssd..sanalik where fisno is not null union all")
			Q("select repsube,sno,'Doğum' as tur,dosyano,dosyaacik,odemetar,fisno,isyerino,pogs,kime,dogodemik as odemik from ssd..sanalik where fisno is not null union all")
			Q("select repsube,sno,'Emzirme' as tur,dosyano,dosyaacik,odemetar,fisno,isyerino,pogs,kime,emzodemik as odemik from ssd..sanalik where fisno is not null) t")
			Q("left join ssd..isyerigenel i on t.isyerino = i.isyerino")
			Q("where sno = :sno order by dosyano, tur")
			Return Process.OpenSQL("*", sno)
		End Function

		Function IsgoremezlikRaporu(ByVal Process As Token, ByVal sno As String) As Recordset
			Q("select a.repsube,a.dosyano,a.ssdodeno as odeno,a.fisno,a.ssdodepogs as odegun,b.pek,b.pogs,b.dosyaacik,a.odebastar,a.odesontar,a.ssdodemik as odemik,a.isvodemik,b.izneciktar")
			Q("from ssd..sagecode a inner join ssd..sagecici b on a.dosyano = b.dosyano and a.sno = b.sno")
			Q("where a.sno = :sno order by a.dosyano")
			Return Process.OpenSQL("*", sno)
		End Function

	End Module
End Namespace
